﻿/*******************************************************
 *  文档管理 相关操作js
 * <p>Title: docManager.js</p>
 * <p>Description:TODO</p>
 * @author Joychen
 * @date 2017年5月22日 下午5:41:57
 * @version 1.0
 * *****************************************************/
var $table, unitzTree, options,//树控件缩略图
    selFolder_id = "", $addOrEditUrl,
    newCount = 1, selNode = null,//选中节点
    checkNodeSpan=null,//选中树id
    upfileData, indexForm,picForm;//上传文档数据
var demo2 = null, pageType = "", doc_type = "",//页面参数类别默认为:收文管理
    doc_name="",//选择节点名称
    $folder_id, $doc_type, $folder_path;
var userID, isDocSys;
var payUser = null;//购买用户
var docManager = {
    //1.初始化页面
    initPage: function (userID,isSys) {
        parent.showLoadBoxs();
        userID = userID;
        isDocSys = isSys;
        docManager.initPageParam();
        docManager.initSelect();
        if (pageType != "VRDevice" && (pageType != "VRBuilding" || doc_type == "4")
            && (pageType != "QDMeta" || doc_type == "4"))
            docManager.initTable();
        //待审核时不需要导航树
        if (doc_type!=5)
            docManager.bindZtree();
        docManager.bindEvent();
        parent.delLoadBoxs();
    },
    //1.1初始化页面参数
    initPageParam:function(){
        pageType = $.getUrls("pageType");
        doc_type = $.getUrls("doc_type");
        if (!pageType)
            pageType = "";
    },
    //2.2采用Ztree初始化文档树
    bindZtree: function () {
        var vrType = $.getUrls("vrType");
        if (!vrType)
            vrType = 5;
        if (unitzTree)
            unitzTree.destroy();
        var setting = {
            view: {
                showIcon: true,
                selectedMulti: false,
                fontCss: getFontCss
            },
            edit:{
                enable: true,               
                showRemoveBtn: false,
                showRenameBtn: false
            },
            async: {
                enable: true,
                dataType: "text",
                type: "post",
                url: ctx + "/DocManager/GetDocTreeData?doc_type=" + doc_type + "&pageType=" + pageType + "&vrType=" + vrType,
                autoParam: ["id"]
            },
            data: {
                key: { title: "name", name: "name" },
                simpleData: { enable: true, idKey: "id", pIdKey: "pId", rootPId: 0 }
            },
            check: {
                enable: false,
                autoCheckTrigger: true,
                chkStyle: "checkbox",
                chkboxType: { "Y": "p", "N": "ps" }
            },
            callback: {
                onAsyncError: function () {
                    layer.msg(Lang.GeneralJson.initUnitError, { icon: 5 });
                },
                onAsyncSuccess: function (event, treeId, treeNode, msg) {
                    //树加载完成后执行
                    var obj = unitzTree.getNodes()[0];
                    if (obj) {
                        unitzTree.selectNode(obj);
                        unitzTree.setting.callback.onClick(null, unitzTree.setting.treeId, obj);//模拟点击事件 
                        if (obj.children && obj.children.length>0)
                            unitzTree.expandNode(obj);
                    }
                },
                onClick: function (event, treeId, treeNode) {
                    $('#unitTree a').css("color", "#333");
                    $('#' + treeNode.tId + '_a').css("color", "#ffffff");
                    checkNodeSpan = treeNode.tId + '_span';
                    selNode = treeNode;//选中节点
                    $folder_id = treeNode.id;
                    $doc_type = treeNode.doc_type;
                    $folder_path = treeNode.folder_path;
                    doc_name = treeNode.name;
                    if ($table && treeNode.id > 0)
                        $table.bootstrapTable('refresh', options);//刷新Table
                },
                //拖拽回调
                //beforeDrag: function (treeId, treeNodes) {
                //    for (var i = 0, l = treeNodes.length; i < l; i++) {
                //        if (!treeNodes[i].drag)
                //            return false;
                //    }
                //    return true;
                //},
                beforeDrop: function (treeId, treeNodes, targetNode, moveType) {
                    return targetNode ? targetNode.drop !== false : true;
                }
            }
        };
        unitzTree = $("#unitTree").initzTreeView(setting, 'ushow', true);
        unitzTree.setting.edit.drag.isCopy = false;
        unitzTree.setting.edit.drag.isMove = true;
        unitzTree.setting.edit.drag.prev = true;
        unitzTree.setting.edit.drag.inner = false;
        unitzTree.setting.edit.drag.next = true;
    },
    //2.2.3验证编辑按钮是否可以用
    checkBtn:function(){
        var node = docManager.getSelNode();
        var row = docManager.selections();
        if (!row)
            return false;
        //0：我的文档，1：我的分享，2：收到的分享，3：公有文档，4：回收站，5：等待审批
        if (node.doc_type === "0" || node.doc_type === "3")
            return true;
        else
            return false;
    },
    //初始化下拉
    initSelect: function () {
        if (!$('#unit_code'))
            return false;
        $.ajax({
            url: ctx + '/SysCommon/GetDictionaryByCode',
            type: "post",
            cache: false,
            async: false,
            data: { fieldCode: 'SysUserUnit' },
            dataType: 'json',
            success: function (data) {
                if (data.Statu === 1) {
                    layer.msg(data.Msg, { icon: 5 });
                    return false;
                }
                var itemStr = "";
                $.each(data.Data, function (i, item) {
                    itemStr += "<option value='" + item.code_value + "'>" + item.code_name + "</option>";
                });
                $('#unit_code').append(itemStr);//单个添加
            }
            //,
            //error: function () {
            //    layer.msg(Lang.GeneralJson.dataException, { icon: 5 });
            //}
        });
        $('#unit_code').selectpicker({ size: 5 });
        $('#unit_code').selectpicker('refresh');
    },
    //2.3初始化Table
    initTable: function () {
        options = {
            url: ctx + "/DocManager/InitTable",
            cutHeight: 5,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            singleSelect: false,//多选
            uniqueId:"file_id",//主键
            toolbar: "#exampleToolbar",
            queryParams: function (params) {
                var pro_type = $('#pro_types'), pro_types;
                if (!pro_type)
                    pro_type = $('#pro_type');
                if (pro_type)
                    pro_types = pro_type.val();
                else
                    pro_types = "-1";
                var vrType = $.getUrls("vrType");
                if (!vrType)
                    vrType = 0;
                var $inChild = "no";
                if ($('#inChild') && $('#inChild').val())
                    $inChild = $('#inChild').val();
                params = {
                    rows: params.limit,
                    //页面大小  
                    page: params.offset / params.limit + 1,
                    folder_id: $folder_id,//节点ID
                    pageType: (doc_type) ? doc_type : 0,//节点类型：我的资源，我的分享
                    doc_type: $doc_type,//页面类型 :1：3D模型，2：文档，3：图片，4：全景图片，5：视频，6：全景视频，7：其他
                    folder_path: $folder_path,
                    inChild: $inChild,//是否包含子目录，空是包含
                    file_status: ($('#FileType')) ? $('#FileType').val() : '',
                    sourceType: ($('#sourceType') && $('#sourceType').val()) ? $('#sourceType').val() : -1,
                    keyword: $('#keyword').val(), //文档名
                    pro_type: pro_types,//($('#pro_type') && $('#pro_type').val()) ? $('#pro_type').val() : "-1",//产品类别 -1:全部
                    file_classify: ($('#file_classify')) ? $('#file_classify').val() : "",//适合分类  空:全部
                    is_recommend: ($('#is_recommend') && $('#is_recommend').val()) ? $('#is_recommend').val() : "-1",//是否推荐 -1:全部
                    mater_type: ($('#mater_type')) ? $('#mater_type').val() : "",//素材格式
                    org_unit: ($('#org_unit')) ? $('#org_unit').val() : "",//所属单位代码  空:全部
                    pro_form: ($('#pro_form') && $('#pro_form').val()) ? $('#pro_form').val() : "-1", //产品形态 -1:全部
                    isHot: ($('#isHot')) ? $('#isHot').val() : "-1", //是否热门推荐
                    goodType: pageType,
                    vrType: vrType
                }
                return params;
            },
            columns: docManager.initTableColumns(),
            onClickRow: function (row, $element) {
            },
            onLoadSuccess: function (data) {
                var val = "";
                if (checkNodeSpan)
                    val = $('#' + checkNodeSpan).text();
                if (data && data.total > 0 && checkNodeSpan) {
                    if (val.indexOf('(') > -1)
                        $('#' + checkNodeSpan).text(val.split('(')[0] + "(" + data.total + ")");
                    else
                        $('#' + checkNodeSpan).text(val + "(" + data.total + ")");
                } else if (val.indexOf('(') > -1 && checkNodeSpan)
                    $('#' + checkNodeSpan).text(val.split('(')[0]);
            }
        }
        $table = tableHelper.initTable("exampleTableToolbar", options);
    },
    //2.3.0 初始化Table表头字段
    initTableColumns: function () {
        var columns;
        //楼宇
        if (pageType === "VRBuilding") {
            columns = [{
                width: 60,
                checkbox: true
            }, {
                    field: '',
                    title: '操作',
                    align: 'center',
                    width: 140,
                    formatter: function (value, row, index) {
                        switch (doc_type) {
                            case "3": {
                                var str = "<button class=\"btn btn-info btn-circle btn-outline\" title=\"" + Lang.GeneralJson.Detail + "\" onclick=\"deviceManager.openDetial(" + row.file_id + ")\" type=\"button\"><i class=\"glyphicon glyphicon-th-large\"></i></button>&nbsp;";
                                str += "<button class=\"btn btn-info btn-circle btn-outline\" title='编辑' onclick=\"deviceManager.getPriceList(" + row.file_id + ")\" type=\"button\"><i class=\"fa fa-pencil\"></i></button>";
                                return str;
                            } break;
                            case "4": {
                                //从下架中恢复
                                return "<button class=\"btn btn-danger btn-circle btn-outline\" title=\"" + Lang.VRGoodManager.VRCloudWork.titleReset + "\" onclick=\"docManager.recoverDocEvent(" + row.file_id + ")\" type=\"button\"><i class=\"fa fa-mail-reply\"></i></button>";
                            } break;
                            default: return index + 1; break;
                        }
                    }
                }, {
                    field: 'alias_name',//缩略图
                    title: '缩略图',
                    align: 'center',
                    width: 70,
                    formatter: function (value, row, index) {
                        return "<button title='" + Lang.VRGoodManager.VRCloudWork.thumbnail + "' onclick=docManager.openPicture(" + row.file_id + ") class='btn btn-primary btn-circle btn-outline'><i class=\"fa fa-picture-o\"></i></button>";
                    }
                }, {
                    field: 'file_code',
                    title: '代码',
                    align: 'center',
                    width: 150,
                    formatter: function (value, row, index) {
                        var folderNum = (row.folder_num) ? row.folder_num : value;
                        if (folderNum && folderNum.toString().length > 15)
                            back = "<span title='" + folderNum + "'>" + folderNum.toString().substring(0, 15) + "...</span>";
                        else
                            back = folderNum;
                        return back;
                    }
                }, {
                    field: 'file_name',
                    title: '名称',
                    align: 'left',
                    width: 110,
                    formatter: function (value, row, index) {
                        var back = "";
                        if (value && value.toString().length > 10)
                            back = "<span title='" + value + "'>" + value.toString().substring(0, 10) + "...</span>";
                        else
                            back = value;
                        return back;
                    }
                }, {
                    field: 'doc_number',
                    title: '楼层',
                    align: 'center',
                    width: 50
                }, {
                    field: 'price',
                    title: '价格',
                    align: 'center',
                    width: 50
                }, {
                    field: 'file_order',
                    title: '序号',
                    align: 'center',
                    width: 40
                }, {
                    field: 'user_name',
                    title: '入住人用户名',
                    align: 'center',
                    width: 100
                }, {
                    field: 'user_phone',
                    title: '入住人手机号',
                    align: 'center',
                    width: 100
                }, {
                    field: 'folder_name',
                    title: '所属目录',
                    align: 'center',
                    width: 100
                }, {
                    field: 'file_note',
                    title: '备注',
                    align: 'center',
                    width: 100,
                    formatter: function (value, row, index) {
                        var back = "";
                        if (value && value.toString().length > 15)
                            back = "<span title='" + value + "'>" + value.toString().substring(0, 15) + "...</span>";
                        else
                            back = value;
                        return back;
                    }
                }, {
                    field: 'update_time',
                    title: Lang.GeneralJson.updateTime,
                    width: 110,
                    align: 'center'
                }, {
                    field: 'update_name',
                    title: '更新人',
                    width: 110,
                    align: 'center'
                }, {
                    field: 'create_time',
                    title: '创建时间',
                    width: 110,
                    align: 'center'
                }, {
                    field: 'create_name',
                    title: '创建人',
                    width: 110,
                    align: 'center'
                }]
        } else {
            //作品
            if (pageType === "VRWorks"){
                //作品
                columns=[
                {
                    width: 60,
                    checkbox: true
                },{
                    field: '',
                    title: Lang.GeneralJson.operation,
                    align: 'center',
                    width: 140,
                    formatter: function (value, row, index) {
                        switch (doc_type) {
                            case "0": {
                                //我的文档 允许设置分享
                                return "<button class=\"btn btn-danger btn-circle btn-outline\" title=\"" + Lang.VRGoodManager.VRCloudWork.titleShare + "\" onclick=\"docManager.shareDocEvent(" + row.file_id + ")\" type=\"button\"><i class=\"fa fa-heart\"></i></button>";
                            } break;
                            //case "2": {
                            //    //收藏夹：新增添加购物车
                            //    return "<button class=\"btn btn-info btn-circle btn-outline\" title=\"添加购物车\" onclick=\"docManager.payGoodsByUser(" + row.file_id + ")\" type=\"button\"><i class=\"fa fa-shopping-cart\"></i></button>";
                            //}
                            case "3": {
                                var str = "<button class=\"btn btn-info btn-circle btn-outline\" title=\"" + Lang.GeneralJson.Detail + "\" onclick=\"docManager.openDetial(" + row.file_id + ")\" type=\"button\"><i class=\"glyphicon glyphicon-th-large\"></i></button>&nbsp;";
                                if (row.file_status != 3)
                                    str += "<button class=\"btn btn-info btn-circle btn-outline\" title=\""+Lang.VRGoodManager.VRCloudWork.titlePay+"\" onclick=\"docManager.payGoods(" + row.file_id + ")\" type=\"button\"><i class=\"fa fa-shopping-cart\"></i></button>&nbsp;";
                                str += "<button class=\"btn btn-info btn-circle btn-outline\" title=\""+Lang.VRGoodManager.VRCloudWork.titleAddColl+"\" onclick=\"docManager.payFolderByUser(" + row.file_id + ")\" type=\"button\"><i class=\"fa fa-folder-open-o\"></i></button>";
                                return str;
                            } break;
                            case "4": {
                                //从下架中恢复
                                return "<button class=\"btn btn-danger btn-circle btn-outline\" title=\"" + Lang.VRGoodManager.VRCloudWork.titleReset + "\" onclick=\"docManager.recoverDocEvent(" + row.file_id + ")\" type=\"button\"><i class=\"fa fa-mail-reply\"></i></button>";
                            } break;                       
                            default: return index + 1; break;
                        }
                    }
                }, {
                    field: 'file_note',
                    title: Lang.VRGoodManager.VRCloudWork.thumbnail,
                    align: 'center',
                    width: 70,
                    formatter: function (value, row, index) {
                        return "<button title='" + Lang.VRGoodManager.VRCloudWork.thumbnail + "' onclick=docManager.openPicture(" + row.file_id + ") class='btn btn-primary btn-circle btn-outline'><i class=\"fa fa-picture-o\"></i></button>";
                    }
                }, {
                    field: 'file_name',
                    title: Lang.VRGoodManager.VRCloudWork.headline,
                    align: 'left',
                    width: 110,
                    formatter: function (value, row, index) {
                        if (value && value.toString().length > 10)
                            back = "<span title='" + value + "'>" + value.toString().substring(0, 10) + "...</span>";
                        else
                            back = value;
                        return back;
                    }
                },{
                    field: 'file_code',
                    title: Lang.VRGoodManager.VRCloudWork.code,
                    align: 'center',
                    width: 150,
                    formatter: function (value, row, index) {
                        if (value && value.toString().length > 15)
                            back = "<span title='" + value + "'>" + value.toString().substring(0, 15) + "...</span>";
                        else
                            back = value;
                        return back;
                    }
                }, {
                    field: 'folder_author',
                    title: Lang.VRGoodManager.VRCloudWork.author,
                    align: 'center',
                    width: 80,
                    formatter: function (value, row, index) {
                        if (value && value.toString().length > 7)
                            back = "<span title='" + value + "'>" + value.toString().substring(0, 7) + "...</span>";
                        else
                            back = value;
                        return back;
                    }
                }, {
                    field: 'pro_form',
                    title: Lang.VRGoodManager.VRCloudWork.productModality,
                    align: 'center',
                    width: 80,
                    formatter: function (value, row, index) {
                        switch (value) {
                            case 1: return "VR"; break;
                            case 2: return Lang.VRGoodManager.VRCloudWork.virtualType; break;
                            case 3: return "AR"; break;
                            default: return "-"; break;
                        }
                    }
                }, {
                    field: 'pro_type_text',
                    title: Lang.VRGoodManager.VRCloudWork.productCategory,
                    align: 'center',
                    width: 80
                    //formatter: function (value, row, index) {
                    //    switch (value) {
                    //        case 1: return "VRPPT"; break;
                    //        case 2: return "创客"; break;
				    //		case 3: return "头记"; break;
                    //        case 4: return "校史馆"; break;
                    //        default: return "-"; break;
                    //    }
                    //}
                }, {
                    field: 'file_classify',
                    title: Lang.VRGoodManager.VRCloudWork.fitClassify,
                    width: 80,
                    align: 'center'
                }, {
                    field: 'file_status',
                    title: Lang.VRGoodManager.VRCloudWork.status,
                    width: 80,
                    align: 'center',
                    formatter: function (value, row, index) {
                        switch (value) {
                            case 0: return "<span class='label label-primary'>" + Lang.VRGoodManager.VRCloudWork.vrPrivate + "</span>"; break;
                            case 1: return "<span class='label label-warning'>" + Lang.VRGoodManager.VRCloudWork.waitApprove + "</span>"; break;
                            case 5: return "<span class='label label-success'>" + Lang.VRGoodManager.VRCloudWork.hasBeenOn + "</span>"; break;
                            case 4: return "<span class='label label-danger'>" + Lang.VRGoodManager.VRCloudWork.removeSth + "</span>"; break;
                            case 6: return "<span class='label label-danger'>" + Lang.VRGoodManager.VRCloudWork.Unapprove + "</span>"; break;
                        }
                    }
                },{
                    field: 'file_money',
                    title: Lang.VRGoodManager.VRCloudWork.price,
                    width: 70,
                    align: 'center',
                    formatter: function (value, row, index) {
                        if (value)
                            return value + Lang.VRGoodManager.VRCloudWork.priceForamt;
                        return 0;
                    }
                },  {
                    field: 'folder_limit',
                    title: Lang.VRGoodManager.VRCloudWork.limit,
                    align: 'center',
                    width: 50
                }];
            }
            //素材
            else{
            columns = [
                {
                    width: 60,
                    checkbox: true
                },{
                    field: '',
                    title: Lang.GeneralJson.operation,
                    align: 'center',
                    width:140,
                    formatter: function (value, row, index) {
                        switch (doc_type) {
                            case "0": {
                                //我的文档 允许设置分享
                                return "<button class=\"btn btn-danger btn-circle btn-outline\" title=\"" + Lang.VRGoodManager.VRCloudWork.titleShare + "\" onclick=\"docManager.shareDocEvent(" + row.file_id + ")\" type=\"button\"><i class=\"fa fa-heart\"></i></button>";
                            } break;
                            //case "2": {
                            //    //收藏夹：新增添加购物车
                            //    return "<button class=\"btn btn-info btn-circle btn-outline\" title=\"添加购物车\" onclick=\"docManager.payGoodsByUser(" + row.file_id + ")\" type=\"button\"><i class=\"fa fa-shopping-cart\"></i></button>";
                            //}
                            case "3": {
                                //添加购物车 
                                var str = "<button class=\"btn btn-info btn-circle btn-outline\" title=\"" + Lang.GeneralJson.Detail + "\" onclick=\"docManager.openDetial(" + row.file_id + ")\" type=\"button\"><i class=\"glyphicon glyphicon-th-large\"></i></button>&nbsp;";
                                if (row.file_status != 3) {
                                    if (pageType === "DDCircle")
                                        str += "<button class=\"btn btn-info btn-circle btn-outline\" title=\"规格管理\" onclick=\"vrManager.specifGoods(" + row.file_id + ",'"+row.file_name+"')\" type=\"button\"><i class=\"fa fa-ellipsis-v\"></i></button>&nbsp;";
                                    else
                                        str += "<button class=\"btn btn-info btn-circle btn-outline\" title=\"编辑\" onclick=\"docManager.editQDFile(" + row.file_id + ")\" type=\"button\"><i class=\"fa fa-pencil\"></i></button>&nbsp;";
                                    //购买
                                    //str += "<button class=\"btn btn-info btn-circle btn-outline\" title=\"" + Lang.VRGoodManager.VRCloudWork.titlePay + "\" onclick=\"docManager.payGoods(" + row.file_id + ")\" type=\"button\"><i class=\"fa fa-shopping-cart\"></i></button>&nbsp;";
                                }    
                                if (pageType === "DDCircle") {
                                    //度度圈：设置/取消热门推荐 fa-fire
                                    var isSoldOut = "btn-info", soldOutTitle = "设置热门推荐";
                                    if (row.isHot) {
                                        isSoldOut = "btn-danger";
                                        soldOutTitle = "取消热门推荐";
                                    }    
                                    str += "<button class=\"btn " + isSoldOut + " btn-circle btn-outline\" title=\"" + soldOutTitle + "\" onclick=\"docManager.payGoodHot(" + row.file_id + "," + row.isHot+")\" type=\"button\"><i class=\"fa fa-fire\"></i></button>";
                                } else if (pageType != "QDMaterial"){
                                    //素材添加收藏夹
                                    str += "<button class=\"btn btn-info btn-circle btn-outline\" title=\"" + Lang.VRGoodManager.VRCloudWork.titleAddColl + "\" onclick=\"docManager.payFolderByUser(" + row.file_id + ")\" type=\"button\"><i class=\"fa fa-folder-open-o\"></i></button>";
                                }
                                return str;
                            } break;
                            case "4": {
                                //从下架中恢复
                                return "<button class=\"btn btn-danger btn-circle btn-outline\" title=\"" + Lang.VRGoodManager.VRCloudWork.titleReset + "\" onclick=\"docManager.recoverDocEvent(" + row.file_id + ")\" type=\"button\"><i class=\"fa fa-mail-reply\"></i></button>";
                            } break;                       
                            default: return index + 1; break;
                        }
                    }
                }, {
                    field: 'file_note',
                    title: Lang.VRGoodManager.VRCloudWork.thumbnail,
                    align: 'center',
                    width: 80,
                    formatter: function (value, row, index) {
                        return "<button title='" + Lang.VRGoodManager.VRCloudWork.thumbnail + "' onclick=docManager.openPicture(" + row.file_id + ") class='btn btn-primary btn-circle btn-outline'><i class=\"fa fa-picture-o\"></i></button>";
                    }
                }, {
                    field: 'mater_type',
                    title: Lang.VRGoodManager.VRCloudWork.materialFormat,
                    width: 90,
                    align: 'center'
                }, {
                    field: 'file_name',
                    title: Lang.VRGoodManager.VRCloudWork.headline,
                    align: 'left',
                    width: 110,
                    formatter: function (value, row, index) {
                        if (value && value.toString().length >10)
                            back = "<span title='" + value + "'>" + value.toString().substring(0, 10) + "...</span>";
                        else
                            back = value;
                        return back;
                    }
                }, {
                    field: 'file_code',
                    title: Lang.VRGoodManager.VRCloudWork.code,
                    align: 'center',
                    width: 150,
                    formatter: function (value, row, index) {
                        //var folderNum = (row.folder_num) ? row.folder_num : value;
                        if (value && value.toString().length > 15)
                            back = "<span title='" + value + "'>" + value.toString().substring(0, 15) + "...</span>";
                        else
                            back = value;
                        return back;
                    }
                }, {
                    field: 'folder_author',
                    title: Lang.VRGoodManager.VRCloudWork.author,
                    align: 'center',
                    width: 80,
                    formatter: function (value, row, index) {
                        if (value && value.toString().length > 7)
                            back = "<span title='" + value + "'>" + value.toString().substring(0, 7) + "...</span>";
                        else
                            back = value;
                        return back;
                    }
                }, {
                    field: 'file_status',
                    title: Lang.VRGoodManager.VRCloudWork.status,
                    width: 80,
                    align: 'center',
                    formatter: function (value, row, index) {
                        switch (value) {
                            case 0: return "<span class='label label-primary'>" + Lang.VRGoodManager.VRCloudWork.vrPrivate + "</span>"; break;
                            case 1: return "<span class='label label-warning'>" + Lang.VRGoodManager.VRCloudWork.waitApprove + "</span>"; break;
                            case 5: return "<span class='label label-success'>" + Lang.VRGoodManager.VRCloudWork.hasBeenOn + "</span>"; break;
                            case 4: return "<span class='label label-danger'>" + Lang.VRGoodManager.VRCloudWork.removeSth + "</span>"; break;
                            case 6: return "<span class='label label-danger'>" + Lang.VRGoodManager.VRCloudWork.Unapprove + "</span>"; break;
                        }
                    }
                },{
                    field: 'file_money',
                    title: Lang.VRGoodManager.VRCloudWork.price,
                    width: 70,
                    align: 'center',
                    formatter: function (value, row, index) {
                        if (value)
                            return value + Lang.VRGoodManager.VRCloudWork.priceForamt;
                        return 0;
                    }
                }, {
                    field: 'file_classify',
                    title: Lang.VRGoodManager.VRCloudWork.fitClassify,
                    width: 80,
                    align: 'center'
                }];
            }
            columns.push({
                field: 'create_time',
                title: Lang.GeneralJson.createTime,
                width: 100,
                align: 'center'
            });
            if (doc_type === 3 || doc_type === "3") {
                columns.push({
                    field: 'is_recommend',
                    title: Lang.VRGoodManager.VRCloudWork.mark,
                    width: 80,
                    align: 'center',
                    formatter: function (value, row, index) {
                        if (value)
                            return "<span class='label label-primary'>" + Lang.VRGoodManager.VRCloudWork.recommended + "</span>";
                        return "<span class='label label-warning'>" + Lang.VRGoodManager.VRCloudWork.notRecommended + "</span>";
                    }
                });
                columns.push({
                    field: 'approve_time',
                    title: Lang.GeneralJson.approveTime,
                    width: 110,
                    align: 'center'
                });
                columns.push({
                    field: 'update_time',
                    title: Lang.GeneralJson.updateTime,
                    width: 110,
                    align: 'center'
                });
                columns.push({
                    field: 'isHot',
                    title: Lang.GeneralJson.hotGood,
                    width: 110,
                    align: 'center',
                    formatter: function (value, row, index) {
                        if (value>0)
                            return "<span class='label label-danger'>" + Lang.VRGoodManager.VRCloudWork.isHot + "</span>";
                        return "";//"<span class='label label-default'>" + Lang.VRGoodManager.VRCloudWork.isHot + "</span>";
                    }
                });
            }
            columns.push({
                field: 'org_unit',
                title: Lang.VRGoodManager.VRCloudWork.belongUnit,
                width: 100,
                align: 'center',
                formatter: function (value, row, index) {
                    if (!value || value === Lang.VRGoodManager.VRCommon.pleaseSelUnit)
                        return "-";
                    return value;
                }
            });
        }
        return columns;
    },
    //2.3.0.1 累计下载次数
    addDownloadNum:function(id){
        $.ajax({
            type: 'post',
            url: ctx + '/DocManager/AddDownloadNum/' + id,
            dataType: 'json',
            async: false,
            success: function (data) {
                if (data.Statu === 0)
                    setTimeout(function () {
                        $table.bootstrapTable('refresh', options);
                    },1000);
                else
                    layer.msg(data.Msg, { icon: 5 });
            }
        });
    },
    //2.3.1回收站恢复
    recoverDocEvent: function (file_id) {
        layer.confirm(Lang.VRGoodManager.VRCommon.vrReset, {
            btn: [Lang.GeneralJson.publicConfirm, Lang.GeneralJson.publicCancel] //按钮
        }, function () {
            var index = layer.msg(Lang.GeneralJson.pleaseWait, { icon: 6, time: 6000 });
            $.ajax({
                type: 'post',
                url: ctx + '/DocManager/RecoverNodeById/' + file_id,
                dataType: 'json',
                async: false,
                success: function (data) {
                    layer.close(index);
                    if (data.Statu === 0) {
                        layer.msg(data.Msg);
                        $table.bootstrapTable('refresh');
                    }
                    else
                        layer.msg(data.Msg, { icon: 5 });
                }
            });
        }, function () { });  
    },
    //2.4 分享文档事件
    shareDocEvent: function (file_id) {
        var index = layer.confirm(Lang.VRGoodManager.VRCommon.shareType, {
            btn: [Lang.VRGoodManager.VRCommon.shareUser, Lang.VRGoodManager.VRCommon.shareRole] //按钮
        }, function () {
            //用户
            docManager.docSetObj(file_id, "/DocManager/GetShareDataByPerson", "/DocManager/SaveDataByPerson", index);
        }, function () {
            //角色
            docManager.docSetObj(file_id, "/DocManager/GetShareDataByRole", "/DocManager/SaveDataByRole", index);
        });
    },
    //2.5 分享文档设置/ 购买用户设置
    docSetObj: function (file_id,$url, $saveurl, index) {
        $.ajax({
            url: ctx + $url,
            type: "post",
            async: false,
            dataType: 'json',
            success: function (mess) {
                if (mess.Statu === 0) {
                    var obj = mess.Data;
                    var selData=null;//已选中人员
                    if (payUser)
                        selData = payUser.split(',');
                    $('.demo1').empty();//清空
                    $.each(obj, function (i, o) {
                        var sel = "";
                        if (selData) {
                            $.each(selData, function (index, item) {
                                if (o['value'] === item.toString()) {
                                    sel = "selected=\"selected\"";
                                    return false;
                                }
                            });
                        }
                        //待选
                        $("<option value='" + o['value'] + "' " + sel + " class='listBoxoption'>" + o['text'] + "</option>").appendTo($('.demo1'));
                    });
                    if (file_id)
                        docManager.initListBox(file_id, $saveurl, index);
                    else 
                        docManager.initPayListBox();
                }
                else
                    layer.open({
                        shade: false,
                        title: false,
                        content: mess.Msg,
                        btn: ''
                    });
            }
            //,
            //error: function () {
            //    layer.msg(Lang.GeneralJson.dataException, { icon: 5 });
            //}
        });
    },
    //2.6 初始化ListBox
    initListBox: function (file_id,$saveUrl, index) {
        if (demo2)
            demo2.bootstrapDualListbox('refresh');
        demo2 = $('.demo1').bootstrapDualListbox({
            nonSelectedListLabel:Lang.GeneralJson.notSelectData, //'未选择数据',
            selectedListLabel:Lang.GeneralJson.selectData, //'已选择数据',
            preserveSelectionOnMove:Lang.GeneralJson.backOut, //'撤销',
            filterTextClear: Lang.GeneralJson.showAll, //'显示全部',
            filterPlaceHolder: Lang.GeneralJson.keyword,// '输入关键字筛选',
            moveSelectedLabel: Lang.GeneralJson.singleSel,// '单个选择',
            moveAllLabel: Lang.GeneralJson.allSel,//'全部选择',
            removeSelectedLabel: Lang.GeneralJson.singleOut,// '单个撤销',
            removeAllLabel: Lang.GeneralJson.allOut,// '全部撤销',
            infoText: Lang.GeneralJson.showAll+'{0}',
            infoTextEmpty: Lang.GeneralJson.notSelectData,// '未选择记录',
            infoTextFiltered: '<span class="label label-warning">' + Lang.GeneralJson.searchData + '</span> {0} ' + Lang.GeneralJson.totalData + ' {1}',
            moveOnSelect: false
        });
        var UnitName = Lang.VRGoodManager.VRCommon.docShareSet;//"文档分享设置";
        var createIndex = layer.open({
            title: [UnitName + '：' + Lang.VRGoodManager.VRCommon.shareTitle, 'font-size:18px;'],
            type: 1,
            content: $('#createDataBySel'),
            scroll: true, //是否显示滚动条、默认不显示
            btn: [Lang.GeneralJson.publicConfirm, Lang.GeneralJson.publicCancel],
            area: ['680px', '450px'],
            success: function (li, o) {
                if (index)
                    layer.close(index);
            },
            yes: function (li, o) {
                //保存数据
                var selData = $('[name="duallistbox_demo1"]').val();
                if (selData) {
                    $.ajax({
                        url: ctx + $saveUrl,
                        type: "post",
                        async: false,
                        data: { "personData": selData.join(','), "file_id": file_id },
                        dataType: 'json',
                        success: function (mess) {
                            if (mess.Statu === 0)
                                layer.msg(mess.Msg, { icon: 6 });
                            else
                                layer.msg(mess.Msg, { icon: 5 });
                            layer.close(createIndex);
                            $table.bootstrapTable('refresh');
                        }
                        //,
                        //error: function () {
                        //    layer.msg(Lang.GeneralJson.dataException, { icon: 5 });
                        //}
                    });
                }
            },
            cancel: function (li, o) {

            }
        });
    },
    //2.7 初始化购买用户设置
    initPayListBox:function(){
        if (demo2)
            demo2.bootstrapDualListbox('refresh');
        demo2 = $('.demo1').bootstrapDualListbox({
            nonSelectedListLabel:Lang.GeneralJson.notSelectData,// '未选择数据',
            selectedListLabel: Lang.GeneralJson.selectData, // '已选择数据',
            preserveSelectionOnMove: Lang.GeneralJson.backOut, // '撤销',
            filterTextClear: Lang.GeneralJson.showAll, //'显示全部',
            filterPlaceHolder: Lang.GeneralJson.keyword,// '输入关键字筛选',
            moveSelectedLabel: Lang.GeneralJson.singleSel,//'单个选择',
            moveAllLabel: Lang.GeneralJson.allSel,//'全部选择',
            removeSelectedLabel: Lang.GeneralJson.singleOut,//'单个撤销',
            removeAllLabel: Lang.GeneralJson.allOut,// '全部撤销',
            infoText: Lang.GeneralJson.showAll + '{0}',
            infoTextEmpty: Lang.GeneralJson.notSelectData,//'未选择记录',
            infoTextFiltered: '<span class="label label-warning">' + Lang.GeneralJson.searchData + '</span> {0} ' + Lang.GeneralJson.totalData + ' {1}',
            moveOnSelect: false
        });
        var payWindow = layer.open({
            id:"payWindow",
            title: [Lang.GeneralJson.buyUserSet + '：' + Lang.VRGoodManager.VRCommon.shareTitle, 'font-size:18px;'],
            type: 1,
            content: $('#createDataBySel'),
            scroll: true, //是否显示滚动条、默认不显示
            btn: [Lang.GeneralJson.publicConfirm, Lang.GeneralJson.publicCancel],
            area: ['680px', '450px'],
            success: function (li, o){
                if (payUser) {
                    //设置默认选中
                }
            },
            yes: function (li, o) {
                //保存数据
                var selData = $('[name="duallistbox_demo1"]').val();
                if (selData)
                    payUser = selData.join(',');
                else
                    payUser = null;
                layer.close(payWindow);
            },
            cancel: function (li, o) {

            }
        });
    },
    //3.0.1关闭文档上传窗口
    closeUpLoadForm: function (data) {
        if (indexForm && data && data.Statu === 0) {
            layer.close(indexForm);
            $table.bootstrapTable('refresh');
        }
    },
    //单独购买
    payGoods:function(file_id){
        if (!file_id) {
            layer.alert('ID Error！', { icon: 5 });
            return false;
        }
        indexForm = layer.open({
            id: 'ifreamDetailData',
            title: [Lang.VRGoodManager.VRCloudWork.titlePay, 'font-size:18px;'],
            type: 2,
            content: ctx + '/ShoppingCart/Index2?fileids=' + file_id,
            scroll: true,//是否显示滚动条、默认不显示
            btn: null,
            area: ['98%', '95%'],
            cancel: function (li, o) {

            }
        });
    },
    //3.事件绑定
    bindEvent: function () {
        //商品折扣
        $('#btnDis').on('click', function () {
            var row = docManager.selections();
            if (!row)
                return false;
            indexForm = layer.open({
                id: 'ifreamDetailData',
                title: [Lang.VRGoodManager.VRCloudWork.disSet, 'font-size:18px;'],
                type: 2,
                content: ctx + '/AccountManager/GoodDisList?fileName=' + encodeURI(row.file_name) + '&fileCode='+row.file_code,
                scroll: true,//是否显示滚动条、默认不显示
                btn: null,
                area: ['98%', '95%'],
                yes: function (li, o) {

                },
                cancel: function (li, o) {

                }
            });
        });
        //批量购买
        $('#btnPay').on('click', function () {
            var row = docManager.selections(true);
            if (!row)
                return false;
            var fileID = new Array();
            $.each(row, function (index, item) {
                fileID.push(item.file_id);
            });
            indexForm = layer.open({
                id: 'ifreamDetailData',
                title: [Lang.VRGoodManager.VRCloudWork.batchBuy, 'font-size:18px;'],
                type: 2,
                content: ctx + '/ShoppingCart/Index2?fileids=' + fileID.join(','),
                scroll: true,//是否显示滚动条、默认不显示
                btn: null,
                area: ['98%', '95%'],
                yes: function (li, o) {

                },
                cancel: function (li, o) {

                }
            });
        });
        //目录菜单图标
        $('#docHeader').on('click', function () {
            if (!$folder_id) {
                layer.msg(Lang.VRGoodManager.VRCommon.pleaseFolderTree, { icon: 5 });
                return false;
            }
            var page = " <div id='createPicturePageHeader' style='overflow-x: hidden;overflow-y:auto;margin-top:10px;margin-right:10px; display: none;'>";
            page += "<div class='form-group' style='position:absolute;right:30px;color:red;'><i class='fa fa-info-circle'></i>&nbsp;" + Lang.VRGoodManager.VRCommon.dbclickDelete + " <button id='btnEditFile' onclick=docManager.openPicUpPage(" + $folder_id + ",'header') class='btn btn-primary' type='button'><i class='fa fa-pencil'></i>&nbsp;" + Lang.VRGoodManager.VRCommon.upLoadImg + "</button></div>";
            page += "<div id='showPictureList' class='form-group' style='margin:20px 5px 15px;'>";
            //获取数据
            $.ajax({
                type: 'post',
                url: ctx + '/SourceManager/GetPicUrlByID/' + $folder_id,
                dataType: 'json',
                data: { picType: 'header', pageType: pageType },
                async: false,
                success: function (data) {
                    if (data.Statu === 0 && data.Url === "header")
                        //目录树缩略图
                        $.each(data.Data, function (i, item) {
                            var folderType = "width:300px;height:220px;";//默认横版：0
                            if (item.folder_type > 0 && item.folder_type === 1)
                                folderType = "width:220px;height:300px;";//竖版：1
                            else if (item.folder_type > 0 && item.folder_type === 2)
                                folderType = "width:300px;height:300px;";//等比：2

                            page += "<div id='img_" + item.folder_id + "' style='width:300px;height:330px;margin-top:20px;margin-left:20px;cursor:pointer;float:left;text-align:center;'><img src='" + item.folder_url.toString().replace("~", window.location.origin + $.ctx()) + "' title='" + Lang.VRGoodManager.VRCommon.dbclickDelete + "' ondblclick=docManager.delPicFileById(''," + item.folder_id + ",'header','" + item.page_type+"') style='" + folderType + "border:1px solid #B2B2B2;border-radius:5px;'/><span>" + item.folder_name + "</span></div>";
                        });
                    else
                        layer.msg(data.Msg, { icon: 5 });
                }
            });
            var pic = $('#createPicturePageHeader');
            if (pic)
                pic.remove();
            //添加图片
            page += "</div></div>";
            $('body').append($(page));
            picForm = layer.open({
                title: [Lang.GeneralJson.icon, 'font-size:18px;'],
                type: 1,
                content: $('#createPicturePageHeader'),
                scroll: true,//是否显示滚动条、默认不显示
                btn: '',
                area: ['700px', '98%'],
                yes: function (li, o) { },
                cancel: function (li, o) { }
            });
        });
        //添加根节点
        $('#docAddPeer').click(function () {
            docManager.addEditNode({ isRoot: true, own: true });
        });
        //添加子级
        $('#docAddChild').click(function () {
            if (!selNode) {
                layer.alert(Lang.VRGoodManager.VRCommon.pleaseNode, { icon: 5 });
                return false;
            }
            if (selNode.if_sys) {
                layer.alert(Lang.GeneralJson.warnTitle+"："+Lang.VRGoodManager.VRCommon.sysNodeError1, { icon: 5 });
                return false;
            }
            //选中节点添加
            if (selNode && selNode.hasOwnProperty("if_create_child") && !selNode.if_create_child) {
                layer.msg(Lang.GeneralJson.warnTitle + "：" + Lang.VRGoodManager.VRCommon.sysNodeError2);
                return false;
            }
            docManager.addEditNode({ isRoot: false, own: false });
        });
        //编辑
        $('#docEdit').click(function () {
            var zTree = $.fn.zTree.getZTreeObj("unitTreezTreeData"),
			nodes = zTree.getSelectedNodes(),
			treeNode = nodes[0];
            if (!treeNode) {
                layer.msg(Lang.VRGoodManager.VRCommon.sysNodeError4, { icon: 7 });
                return false;
            }
            //判断当前节点是否允许被编辑
            if (treeNode.hasOwnProperty("read_only") && treeNode.read_only) {
                layer.msg(Lang.GeneralJson.warnTitle + "：" + Lang.VRGoodManager.VRCommon.sysNodeError3);//只读
                return false;
            }
            docManager.addEditNode(treeNode);
        });
        //删除
        $('#docDel').click(function () {
            docManager.editRemove();
        });
        //查询
        $('#btnSearch').click(function () {
            if (doc_type != 5) {
                var zTree = docManager.getSelNode();
                if (!zTree) {
                    layer.msg(Lang.GeneralJson.warnTitle + "：" + Lang.VRGoodManager.VRCommon.sysNodeError5, { icon: 1 });
                    return false;
                }
            }
            $table.bootstrapTable('refresh',options);
        });
        //系统操作
        //添加系统根节点
        $('#docAddSysPeer').click(function () {
            docManager.addOrEditSysNode({ isRoot: true });
        });
        //添加系统子节点
        $('#docAddSysChild').click(function () {
            docManager.addOrEditSysNode({ isRoot: false });
        });
        //编辑系统节点
        $('#docSysEdit').click(function () {
            var zTree = $.fn.zTree.getZTreeObj("unitTreezTreeData"),
			nodes = zTree.getSelectedNodes(),
			treeNode = nodes[0];
            if (!treeNode) {
                layer.msg(Lang.VRGoodManager.VRCommon.sysNodeError4, { icon: 7 });
                return false;
            }
            docManager.addOrEditSysNode(treeNode);
        });
        //待审核资源
        $('#btnApproveFile').click(function () {
            var row = docManager.selections();
            if (!row)
                return false;
            indexForm = layer.open({
                id: 'ifreamUpLoadData',
                title: [Lang.GeneralJson.approveDoc, 'font-size:18px;'],
                type: 2,
                content: ctx + '/SourceManager/EntryFileApprove?file_id=' + row.file_id + '&pageType=' + pageType + '&doc_type=' + doc_type + '&entryType=approve',
                scroll: true,//是否显示滚动条、默认不显示
                btn: [Lang.GeneralJson.publicConfirm, Lang.GeneralJson.publicCancel],
                area: ['98%', '95%'],
                yes: function (li, o) {
                    var result = document.getElementById("ifreamUpLoadData").firstChild.contentWindow.entryManager.saveForm(indexForm);
                    $table.bootstrapTable('refresh', options);
                    if (result)
                        layer.closeAll();
                },
                cancel: function (li, o) {

                }
            });
        });
        //上传文档
        $('#btnUploadFile').click(function () {
            //pc新增文档暂时停用
            layer.alert(Lang.GeneralJson.warnTitle+"："+Lang.VRGoodManager.VRCommon.sysNodeError6);
            return false;
            //var node = docManager.getSelNode();
            //if (!node) {
            //    layer.msg("温馨提示：上传文档请先选择需要上传的目录！");
            //    return false;
            //}
            ////判断是否能够上传资源
            //if (!$doc_type || $doc_type === 0 || !doc_name) {
            //    layer.msg("请选择具体某个素材类型，再上传资源！");
            //    return false;
            //}
            ////打开编辑
            //indexForm = layer.open({
            //    id: 'ifreamUpLoadData',
            //    title: [node.name + '：上传文档', 'font-size:18px;'],
            //    type: 2,
            //    content: ctx + '/DocManager/DocUpLoadFile?doc_name=' + encodeURIComponent(doc_name) + '&jsFileType=sourceManager&folder_id=' + node.id,
            //    scroll: true,//是否显示滚动条、默认不显示
            //    btn: [Lang.GeneralJson.publicConfirm, Lang.GeneralJson.publicCancel],
            //    area: ['800px', '98%'],
            //    yes: function (li, o) {
            //        var menuData = document.getElementById("ifreamUpLoadData").firstChild.contentWindow.upLoadDoc();
            //        if (menuData === null)
            //            return false;
            //    },
            //    cancel: function (li, o) {

            //    }
            //});
        });
        //编辑
        $('#btnEditFile').click(function () {
            if (!docManager.checkBtn()) 
                return false;
            var row = docManager.selections();
            if (!row)
                return false;
            //我的作品、素材时 只允许编辑《私有、待审核、已下架》
            if ((doc_type === 0 || doc_type === "0") && (row.file_status === 5 || row.file_status === 6)) {
                layer.alert(Lang.VRGoodManager.VRCommon.nodeEditError1, { icon: 5 });
                return false;
            }
            indexForm = layer.open({
                id: 'ifreamUpLoadData',
                title: [Lang.GeneralJson.Edit, 'font-size:18px;'],
                type: 2,
                content: ctx + '/SourceManager/EntryFile/' + row.file_id + '?file_id=' + row.file_id + '&pageType=' + pageType + '&doc_type=' + doc_type,
                scroll: true,//是否显示滚动条、默认不显示
                btn: [Lang.GeneralJson.publicConfirm, Lang.GeneralJson.publicCancel],
                area: ['98%', '95%'],
                yes: function (li, o) {
                    var result = document.getElementById("ifreamUpLoadData").firstChild.contentWindow.entryManager.saveForm();
                    $table.bootstrapTable('refresh', options);
                    if(result)
                        layer.closeAll();
                },
                cancel: function (li, o) {

                }
            });
        });
        //附件列表
        $('#btnFileList').on('click', function () {
            if (!docManager.checkBtn())
                return false;
            var row = docManager.selections();
            if (!row)
                return false;
            indexForm = layer.open({
                id: 'ifreamFileListData',
                title: [Lang.GeneralJson.Edit, 'font-size:18px;'],
                type: 2,
                content: ctx + '/SourceManager/EntryFileList?file_id=' + row.file_id,
                scroll: true,//是否显示滚动条、默认不显示
                btn: [Lang.GeneralJson.publicConfirm, Lang.GeneralJson.publicCancel],
                area: ['1000px', '95%'],
                yes: function (li, o) {
                    document.getElementById("ifreamFileListData").firstChild.contentWindow.fileListManager.saveForm();
                },
                cancel: function (li, o) {

                }
            });
        });
        //详细
        $('#btnFileDetial').on('click', function () {
            var row = docManager.selections();
            if (!row)
                return false;
            var index1 = layer.open({
                id: 'ifreamDetailData',
                title: [Lang.GeneralJson.Detail, 'font-size:18px;'],
                type: 2,
                content: ctx + '/SourceManager/EntryFile/' + row.file_id + '?read=only&file_id=' + row.file_id,
                scroll: true,//是否显示滚动条、默认不显示
                btn: [Lang.GeneralJson.publicConfirm],
                area: ['98%', '95%'],
                yes: function (li, o) {
                    if(index1)
                        layer.close(index1);
                },
                cancel: function (li, o) {

                }
            });
        });
        //删除，下架，撤销分享等删除操作
        $('#btnDeleteFile').click(function () {
            var node = docManager.getSelNode();
            if (!node) {
                layer.msg("数据为空！", { icon: 5 });
                return false;
            }
            var row = (node.doc_type === "0" || node.doc_type === "3" || node.doc_type === "4") ? docManager.selections(true) : docManager.selections();
            if (!row)
                return false;
            var reason = "", $url = "", $fileId = "";
            //0：我的文档（我的资源），
            //1：我的分享，撤销分享（可以撤销多个分享）
            //2：收到的分享，撤销分享（只能撤销一个）
            //3：公有文档（VR资源），管理员可删除
            //4：回收站（下架资源）
            //5：待审核资源
            //如果是VR资源(公用文档 需要是管理员才能进行下架操作)
            if (node.doc_type === "3" && isDocSys.toLowerCase() != "true") {
                layer.msg(Lang.GeneralJson.warnTitle+"："+Lang.VRGoodManager.VRCommon.docOperator1, { icon: 5 });
                return false;
            }
            switch (node.doc_type) {
                case "1": {
                    //我的分享，撤销分享（可以撤销多个分享）
                    $url = "/DocManager/RemoveMyShareById/" + row.file_id;
                    reason = Lang.VRGoodManager.VRCommon.docOperator2;
                } break;
                case "2": {
                    //收到的分享，撤销分享（只能撤销一个）
                    $url = "/DocManager/RemoveFileToMeById/" + row.file_id;
                    reason = Lang.VRGoodManager.VRCommon.docOperator3;
                } break;
                case "3": {
                    //VR资源，下架操作（回收站）
                    $url = "/DocManager/RemoveNodeById";
                    reason = Lang.VRGoodManager.VRCommon.docOperator4;
                    var $actData = new Array();
                    $.each(row, function (index, item) {
                        $actData.push(item.file_id);
                    });
                    $fileId = $actData.join(',');
                } break;
                case "4": {
                    //彻底删除DelNodeById
                    $url = "/DocManager/DelNodeById";
                    reason = Lang.VRGoodManager.VRCommon.docOperator5;
                    var $actData = new Array();
                    $.each(row, function (index, item) {
                        $actData.push(item.file_id);
                    });
                    $fileId = $actData.join(',');
                } break;
                default: {
                    //我的资源：彻底删除
                    $url = "/DocManager/DelNodeById";
                    reason = Lang.VRGoodManager.VRCommon.docOperator6;
                    var $actData = new Array();
                    $.each(row, function (index, item) {
                        $actData.push(item.file_id);
                    });
                    $fileId = $actData.join(',');
                } break;
            }
            layer.confirm(reason, {
                btn: [Lang.GeneralJson.publicConfirm, Lang.GeneralJson.publicCancel] //按钮
            }, function () {
                var index = layer.msg(Lang.GeneralJson.pleaseWait, { icon: 6, time: 6000 });
                $.ajax({
                    type: 'post',
                    url: ctx + $url,
                    dataType: 'json',
                    async: false,
                    data: { fileId:$fileId},
                    success: function (data) {
                        layer.close(index);
                        if (data.Statu === 0) {
                            layer.msg(data.Msg);
                            $table.bootstrapTable('refresh');
                        }
                        else
                            layer.msg(data.Msg, { icon: 5 });
                    }
                });
            }, function () { });
        });
        //推荐管理
        $('#btnRecommendFile').on('click', function () {
            var row = docManager.selections(true);
            if (!row)
                return false;
            var $actData = new Array();
            $.each(row, function (index, item) {
                $actData.push(item.file_id);
            });
            layer.confirm(Lang.VRGoodManager.VRCommon.docOperator7, {
                btn: [Lang.GeneralJson.publicConfirm, Lang.GeneralJson.publicCancel] //按钮
            }, function () {
                var index = layer.msg(Lang.GeneralJson.pleaseWait, { icon: 6, time: 6000 });
                $.ajax({
                    type: 'post',
                    url: ctx + '/DocManager/RecommendFileByID',
                    dataType: 'json',
                    data: { fileId: $actData.join(','), relType: 1 },
                    async: false,
                    success: function (data) {
                        layer.close(index);
                        if (data.Statu === 0) {
                            layer.msg(data.Msg);
                            $table.bootstrapTable('refresh');
                        }
                        else
                            layer.msg(data.Msg, { icon: 5 });
                    }
                });
            }, function () { });
        });
        //取消推荐
        $('#btnNotRecommendFile').on('click', function () {
            var row = docManager.selections(true);
            if (!row)
                return false;
            var $actData = new Array();
            $.each(row, function (index, item) {
                $actData.push(item.file_id);
            });
            layer.confirm(Lang.VRGoodManager.VRCommon.docOperator8, {
                btn: [Lang.GeneralJson.publicConfirm, Lang.GeneralJson.publicCancel] //按钮
            }, function () {
                var index = layer.msg(Lang.GeneralJson.pleaseWait, { icon: 6, time: 6000 });
                $.ajax({
                    type: 'post',
                    url: ctx + '/DocManager/RecommendFileByID',
                    dataType: 'json',
                    data: { fileId: $actData.join(','), relType: 0 },
                    async: false,
                    success: function (data) {
                        layer.close(index);
                        if (data.Statu === 0) {
                            layer.msg(data.Msg);
                            $table.bootstrapTable('refresh');
                        }
                        else
                            layer.msg(data.Msg, { icon: 5 });
                    }
                });
            }, function () { });
        });
        //设置购买用户
        $('#btnPayFileUser').on('click', function () {
            //设置用户
            docManager.docSetObj(null, "/DocManager/GetShareDataByPerson", null, null);
        });
        //批量编辑
        $('#btnBatch').on('click', function () {
            var row = docManager.selections(true);
            if (!row)
                return false;
            var fileID = new Array();
            $.each(row, function (index, item) {
                fileID.push(item.file_id);
            });
            var indexBatch = layer.open({
                title: [Lang.VRGoodManager.VRCloudWork.batchEdit, 'font-size:18px;'],
                type: 1,
                content: $('#BatchEditFile'),
                scroll: true,//是否显示滚动条、默认不显示
                btn: [Lang.GeneralJson.publicConfirm, Lang.GeneralJson.publicCancel],
                area: ['500px', '90%'],
                yes: function (li, o) {
                    var folder_id = $('#folder_id').val(), file_classify = $('#fileClassify').val(), org_unit = $('#orgUnit').val();
                    if (!folder_id) {
                        layer.alert(Lang.GeneralJson.pleaseSelect+Lang.VRGoodManager.VRCloudWork.scope, { icon: 5 });
                        return false;
                    }
                    if (!file_classify) {
                        layer.alert(Lang.GeneralJson.pleaseSelect + Lang.VRGoodManager.VRCloudWork.fitClassify, { icon: 5 });
                        return false;
                    }
                    //if (!org_unit) {
                    //    layer.alert("请选择所属单位！", { icon: 5 });
                    //    return false;
                    //}
                    var index = layer.msg(Lang.GeneralJson.pleaseWait, { icon: 6, time: 6000 });
                    $.ajax({
                        type: 'post',
                        url: ctx + '/SourceManager/SaveBatchData',
                        dataType: 'json',
                        async: false,
                        data: {
                            file_id: fileID.join(','),
                            folder_id: $('#folder_id').val(),
                            folder_path: $('#folder_path').val(),
                            file_classify: $('#fileClassify').val(),
                            org_unit: $('#orgUnit').val(),
                            unit_name: encodeURIComponent($('#orgUnit').find("option:selected").text())
                        },
                        success: function (data) {
                            layer.close(index);
                            if (data.Statu === 0) {
                                layer.msg(data.Msg);
                                $table.bootstrapTable('refresh');
                                if (indexBatch)
                                    layer.close(indexBatch);
                            }
                            else
                                layer.msg(data.Msg, { icon: 5 });
                        }
                    });
                },
                cancel: function (li, o) {

                }
            });
        });
    },
    //编辑
    editQDFile: function (file_id) {
        var row = $table.bootstrapTable('getRowByUniqueId', file_id);
        //我的作品、素材时 只允许编辑《私有、待审核、已下架》
        if ((doc_type === 0 || doc_type === "0") && (row.file_status === 5 || row.file_status === 6)) {
            layer.alert(Lang.VRGoodManager.VRCommon.nodeEditError1, { icon: 5 });
            return false;
        }
        indexForm = layer.open({
            id: 'ifreamUpLoadData',
            title: [Lang.GeneralJson.Edit, 'font-size:18px;'],
            type: 2,
            content: ctx + '/SourceManager/EntryFile/' + row.file_id + '?file_id=' + row.file_id + '&pageType=' + pageType + '&doc_type=' + doc_type,
            scroll: true,//是否显示滚动条、默认不显示
            btn: [Lang.GeneralJson.publicConfirm, Lang.GeneralJson.publicCancel],
            area: ['98%', '95%'],
            yes: function (li, o) {
                var result = document.getElementById("ifreamUpLoadData").firstChild.contentWindow.entryManager.saveForm();
                $table.bootstrapTable('refresh', options);
                if (result)
                    layer.closeAll();
            },
            cancel: function (li, o) {

            }
        });
    },
    //关闭窗口
    closeIndexForm:function(form){
        if (form) 
            layer.close(form);
        $table.bootstrapTable('refresh', options);
    },
    //3.0.0 详细
    openDetial: function (file_id) {
        if (!file_id)
            return false;
        var index1 = layer.open({
            id: 'ifreamDetailData',
            title: [Lang.GeneralJson.Detail, 'font-size:18px;'],
            type: 2,
            content: ctx + '/SourceManager/EntryFile/' + file_id + '?read=only&file_id=' + file_id,
            scroll: true,//是否显示滚动条、默认不显示
            btn: [Lang.GeneralJson.publicConfirm],
            area: ['98%', '95%'],
            yes: function (li, o) {
                if (index1)
                    layer.close(index1);
                $table.bootstrapTable('refresh', options);
            },
            cancel: function (li, o) {

            }
        });
    },
    //3.0.0 获取选中行记录
    selections: function (isAll) {
        var row = $table.bootstrapTable('getSelections');
        if (!row || row.length === 0) {
            layer.msg(Lang.GeneralJson.dataIsNull, { icon: 5 });
            return false;
        }
        if (isAll)
            return row;
        if (row.length > 1) {
            layer.msg(Lang.GeneralJson.dataSelEroor, { icon: 5 });
            return false;
        }
        return row[0];
    },
    //3.1获取被选中节点
    getSelNode: function () {
        //获取页面doc_type参数
        //获取节点folder_id参数
        var zTree = $.fn.zTree.getZTreeObj("unitTreezTreeData");
        if (!zTree)
            return null;
        var nodes = zTree.getSelectedNodes();
        if (!nodes || nodes.length === 0)
            return null;
        var treeNode = nodes[0];
        treeNode.doc_type = doc_type;
        return treeNode;
    },
    //4.添加，编辑【普通节点】
    addEditNode: function (e) {
        $('#langCodeNode').text('');
        $('#folderPathNode').text('');
        var title = Lang.GeneralJson.Add;
        if (!e.hasOwnProperty("isRoot"))
            title = Lang.GeneralJson.Edit;
        $('#addNode').val("");
        $('#enLangNode').val("");
        $('#group_name1').val("");
        $('#folder_order1').val("");
        //打开编辑
        layer.open({
            title: [title, 'font-size:18px;'],
            type: 1,
            content: $('#EditNode'),
            scroll: true,//是否显示滚动条、默认不显示
            btn: [Lang.GeneralJson.publicConfirm, Lang.GeneralJson.publicCancel],
            area: ['480px', '400px'],
            success: function (li, o) {
                if (e != null) {
                    var lang = docManager.getLanguage();
                    if (lang === "en") {
                        //英文
                        if (e.name && e.name.indexOf("(") > -1)
                            $('#enLangNode').val(e.name.split('(')[0]);
                        else if (e.name)
                            $('#enLangNode').val(e.name);
                        if (e.enLang)
                            $('#addNode').val(e.enLang);
                    } else {
                        //中文
                        if (e.name && e.name.indexOf("(") > -1)
                            $('#addNode').val(e.name.split('(')[0]);
                        else if (e.name)
                            $('#addNode').val(e.name);
                        if (e.enLang)
                            $('#enLangNode').val(e.enLang);
                    }
                    if (e.langCode)
                        $('#langCodeNode').text(e.langCode);
                    if (e.folder_path)
                        $('#folderPathNode').text(e.folder_path);
                    if (e.pro_type)
                        $('#proType1').selectpicker('val', e.pro_type.toString());
                    if (e.hasOwnProperty("is_share"))
                        $('#isShare').selectpicker('val', e.is_share.toString());
                    if (e.folder_order)
                        $('#folder_order1').val(e.folder_order);
                    if (e.group_name)
                        $('#group_name1').val(e.group_name);
                }
            },
            yes: function (li, o) {
                var name = $('#addNode').val(),
                    enLangNode = $('#enLangNode').val(),
                    proType = $('#proType1').val(),
                    group_name = $('#group_name1').val(),
                    folder_order = $('#folder_order1').val(),
                    if_private1 = $('#if_private1').val(),
                    is_share = $('#isShare').val(),
                    if_limit1 = $('#if_limit1').val();
                var row = {
                    enLang: enLangNode,
                    if_private1: if_private1,
                    if_limit1: if_limit1,
                    is_share: is_share
                };
                if (!name || name.length === 0) {
                    layer.msg(Lang.GeneralJson.warnTitle + "：" + Lang.VRGoodManager.VRCloudWork.nodeName + Lang.GeneralJson.required);
                    return false;
                }
                if (!e.hasOwnProperty("isRoot"))
                    docManager.editNode(e, name, proType, folder_order, group_name, row);
                else
                    docManager.addNode(e, name, proType, folder_order, group_name, row);
            },
            cancel: function (li, o) {

            }
        });
    },
    //4.1添加节点：同级节点/子节点
    addNode: function (e, nodeName, proType, folder_order, group_name,dataRow) {
        var zTree = $.fn.zTree.getZTreeObj("unitTreezTreeData"),
			nodes = zTree.getSelectedNodes(),//当前选择节点
            isParent = e.isParent,
			treeNode = nodes[0];
        var dataJson = {
            "pId": (e.isRoot) ? 0 : treeNode.id,
            "name": nodeName,
            "pageType": pageType,
            "proType": proType,
            "folder_order": folder_order,
            "group_name": encodeURIComponent(group_name),
            "if_private": dataRow.if_private1,
            "if_limit": dataRow.if_limit1,
            "enLang": dataRow.enLang,
            "is_share": dataRow.is_share
        };
        //后台先添加
        $.ajax({
            url: ctx + '/DocManager/AddNode',
            type: "post",
            async: false,
            dataType: 'json',
            data: dataJson,
            success: function (result) {
                parent.delLoadBoxs();
                if (result.Statu === 0) {
                    if (e.isRoot)
                        //添加根节点
                        zTree.addNodes(null, { id: result.Data, pId: 0, isParent: false, name: nodeName, pro_type: proType, folder_order: folder_order, group_name: group_name, if_private: dataRow.if_private1, if_limit: dataRow.if_limit1, enLang: dataRow.enLang, is_share: dataRow.is_share });
                    else
                        zTree.addNodes(treeNode, { id: result.Data, pId: treeNode.id, isParent: false, name: nodeName, pro_type: proType, folder_order: folder_order, group_name: group_name, if_private: dataRow.if_private1, if_limit: dataRow.if_limit1, enLang: dataRow.enLang, is_share: dataRow.is_share });
                    selNode = treeNode;
                    layer.closeAll();
                } 
                layer.msg(result.Msg);
            }
            //,
            //error: function () {
            //    parent.delLoadBoxs();
            //    layer.msg(Lang.GeneralJson.dataException, { icon: 5 });
            //}
        });
    },
    //4.2编辑节点
    editNode: function (treeNode, nodeName, proType, folder_order, group_name,dataRow) {
        var zTree = $.fn.zTree.getZTreeObj("unitTreezTreeData");
        //后台编辑
        $.ajax({
            url: ctx + '/DocManager/EditNode',
            type: "post",
            async: false,
            dataType: 'json',
            data: { "id": treeNode.id, "name": nodeName, "proType": proType, "folder_order": folder_order, "group_name": encodeURIComponent(group_name), if_private: dataRow.if_private1, if_limit: dataRow.if_limit1, "enLang": dataRow.enLang, "is_share": dataRow.is_share },
            success: function (result) {
                if (result.Statu === 0) {
                    treeNode.name = nodeName;
                    treeNode.enLang = dataRow.enLang;
                    treeNode.is_share = dataRow.is_share;
                    treeNode.pro_type = proType;
                    treeNode.folder_order = folder_order;
                    treeNode.group_name = group_name;
                    treeNode.if_private = dataRow.if_private1;
                    treeNode.if_limit = dataRow.if_limit1;
                    zTree.updateNode(treeNode);
                    layer.closeAll();
                }
                layer.msg(result.Msg);
            }
            //,
            //error: function () {
            //    layer.msg(Lang.GeneralJson.dataException, { icon: 5 });
            //}
        });
    },
    //5.删除节点
    editRemove: function (e) {
        layer.msg(Lang.GeneralJson.pleaseWait, { icon: 1, time: 5000 });
        var zTree = $.fn.zTree.getZTreeObj("unitTreezTreeData"),
			nodes = zTree.getSelectedNodes(),
			treeNode = nodes[0];
        if (!treeNode) {
            layer.msg(Lang.VRGoodManager.VRCommon.nodeTitle1,{icon:7});
            return false;
        }
        //判断当前节点是否允许被编辑
        if (treeNode.hasOwnProperty("read_only") && treeNode.read_only) {
            layer.msg(Lang.GeneralJson.warnTitle+"："+Lang.VRGoodManager.VRCommon.sysNodeError7);//只读
            return false;
        }
        layer.confirm(Lang.VRGoodManager.VRCommon.nodeOperTitle1, {
            btn: [Lang.GeneralJson.publicConfirm, Lang.GeneralJson.publicCancel] //按钮
        }, function () {
            //后台删除
            $.ajax({
                url: ctx + '/DocManager/DeleteNode',
                type: "post",
                async: false,
                dataType: 'json',
                data: { "id": treeNode.id },
                success: function (result) {
                    if (result.Statu === 0) {
                        zTree.removeNode(treeNode);
                        selNode = null;
                    }
                    layer.msg(result.Msg);
                }
                //,
                //error: function () {
                //    layer.msg(Lang.GeneralJson.dataException, { icon: 5 });
                //}
            });
        }, function () { });
    },
    //6.操作系统节点
    addOrEditSysNode: function (e) {
        $('#langCode').text('');
        $('#folderPath').text('');
        //隐藏父目录下拉
        var parentTree=$('#parentTree');
        if(parentTree){
            //关闭
            $('#parentTree').slideUp();
            parentFolder = false;
        }
        var pid = 0;//默认添加根节点
        var zTree = $.fn.zTree.getZTreeObj("unitTreezTreeData"),
			nodes = zTree.getSelectedNodes(),
			treeNode = nodes[0];
        var orderId = "";//原始序号
        if (treeNode)
            orderId = treeNode.folder_order;//原始序号
        if (!treeNode && !e.isRoot)
            e.isRoot = true;
        //添加
        if (e.hasOwnProperty("isRoot")) {
            if(!e.isRoot)
                pid = treeNode.id;//添加子节点
        } else if(!treeNode){
            layer.msg(Lang.GeneralJson.warnTitle+"："+Lang.VRGoodManager.VRCommon.nodeOperTitle2);
            return false;
        } else
            pid = treeNode.pId;//编辑
        $('#pId').val(pid);
        $('#pageType').val(pageType);
        var title = Lang.GeneralJson.addNode;
        $addOrEditUrl = ctx + "/DocManager/AddSysNode";//新增
        if (!e.hasOwnProperty("isRoot")) {
            title = Lang.GeneralJson.editNode;
            $addOrEditUrl = ctx + "/DocManager/EditSysNode/" + treeNode.id;//编辑
        }
        //清空表单
        $('#nodeFormTable').resetHideValidForm();
        //打开编辑
        layer.open({
            title: [title, 'font-size:18px;'],
            type: 1,
            content: $('#nodeForm'),
            scroll: true,//是否显示滚动条、默认不显示
            btn: [Lang.GeneralJson.publicConfirm, Lang.GeneralJson.publicCancel],
            area: ['500px', '90%'],
            success: function (li, o) {
                if (e && !e.hasOwnProperty("isRoot")) {
                    $('#nodeFormTable')[0].reset();//重置表单                
                    if (e.hasOwnProperty("pro_type") && e.pro_type === 0)
                        e.pro_type = 1;
                    $('#nodeFormTable').autoLoadForm(e);//表单填充数据
                    $('#pName').val(e.pName);
                    $('#pId').val(e.pId);//父目录id
                    $('#pPath').val(e.pPath);//父目录path
                    if (e.langCode)
                        $('#langCode').text(e.langCode);
                    if (e.folder_path)
                        $('#folderPath').text(e.folder_path);
                    var lang = docManager.getLanguage();
                    if (lang === "en") {
                        //英文
                        if (e.name.indexOf("(") > -1)
                            $('#enLang').val(e.name.split('(')[0]);
                        else
                            $('#enLang').val(e.name);
                        $('#name').val(e.enLang);
                    } else {
                        //中文
                        if (e.name.indexOf("(") > -1)
                            $('#name').val(e.name.split('(')[0]);
                        else
                            $('#name').val(e.name);
                    }
                    $('#pId').val(e.pId);
                } else {
                    if (!selNode)
                        return false;
                    var pname = selNode.name;
                    if (pname.indexOf("(") > -1)
                        pname = pname.split("(")[0];
                    $('#pName').val(pname);
                }
            },
            yes: function (li, o) {
                if ($('#nodeFormTable').valid()) {
                    //验证通过
                    $('#nodeFormTable').ajaxSubmit({
                        url: $addOrEditUrl,
                        type: "post",
                        dataType: "json",
                        beforeSubmit: function (arr, $form, options) {
                            layer.msg(Lang.GeneralJson.dataProcessing, { icon: 1, time: 5000 });
                        },
                        success: function (result, status, xhr, $form) {
                            if (result.Statu === 0) {
                                layer.closeAll();
                                var nodes = result.Data;
                                if (nodes.floor_level)
                                    nodes.floor_level = nodes.floor_level.replace(/，/g, ",");
                                var isInit = false;//是否需要重置树
                                if (e.hasOwnProperty("isRoot")) {
                                    //添加
                                    if (e.isRoot)
                                        //添加根节点
                                        zTree.addNodes(null, { id: nodes.id, pId: 0, isParent: false, name: nodes.name, if_create_child: nodes.if_create_child, read_only: nodes.read_only, was_share: nodes.was_share, if_sys: nodes.if_sys, doc_type: nodes.doc_type, folder_note: nodes.folder_note, pro_type: nodes.pro_type, unit_code: nodes.unit_code, folder_order: nodes.folder_order, group_name: nodes.group_name, if_private: nodes.if_private, if_limit: nodes.if_limit, materType: nodes.materType, re_folder: nodes.re_folder, enLang: nodes.enLang, is_recommend: nodes.is_recommend, is_share: nodes.is_share, pName: nodes.pName, pPath: nodes.pPath, folder_path: nodes.folder_path, founder_login: nodes.founder_login, gps_x: nodes.gps_x, gps_y: nodes.gps_y, bs_type: nodes.bs_type, floor_level: nodes.floor_level, statr_partner: nodes.statr_partner, city: nodes.city, addr: nodes.addr, sortType: nodes.sortType});
                                    else
                                        zTree.addNodes(treeNode, { id: nodes.id, pId: nodes.pId, isParent: false, name: nodes.name, if_create_child: nodes.if_create_child, read_only: nodes.read_only, was_share: nodes.was_share, if_sys: nodes.if_sys, doc_type: nodes.doc_type, folder_note: nodes.folder_note, pro_type: nodes.pro_type, unit_code: nodes.unit_code, folder_order: nodes.folder_order, group_name: nodes.group_name, if_private: nodes.if_private, if_limit: nodes.if_limit, materType: nodes.materType, re_folder: nodes.re_folder, enLang: nodes.enLang, is_recommend: nodes.is_recommend, is_share: nodes.is_share, pName: nodes.pName, pPath: nodes.pPath, folder_path: nodes.folder_path, founder_login: nodes.founder_login, gps_x: nodes.gps_x, gps_y: nodes.gps_y, bs_type: nodes.bs_type, floor_level: nodes.floor_level, statr_partner: nodes.statr_partner, city: nodes.city, addr: nodes.addr, sortType: nodes.sortType });
                                } else {
                                    //编辑
                                    if (treeNode.name.indexOf('(') > -1) 
                                        treeNode.name = nodes.name + "(" + treeNode.name.split('(')[1];
                                    else
                                        treeNode.name = nodes.name;
                                    if (treeNode.pId != nodes.pId)
                                        isInit = true;
                                    treeNode.enLang = nodes.enLang;
                                    treeNode.is_recommend = nodes.is_recommend;
                                    treeNode.is_share = nodes.is_share;
                                    treeNode.if_create_child = nodes.if_create_child;
                                    treeNode.read_only = nodes.read_only;
                                    treeNode.was_share = nodes.was_share;
                                    treeNode.if_sys = nodes.if_sys;
                                    treeNode.doc_type = nodes.doc_type;
                                    treeNode.folder_note = nodes.folder_note;
                                    treeNode.pro_type = nodes.pro_type;
                                    treeNode.unit_code = nodes.unit_code;
                                    treeNode.folder_order = nodes.folder_order;
                                    treeNode.group_name = nodes.group_name;
                                    treeNode.if_private = nodes.if_private;
                                    treeNode.if_limit = nodes.if_limit;
                                    treeNode.materType = nodes.materType;
                                    treeNode.re_folder = nodes.re_folder;
                                    treeNode.pId = nodes.pId;//父目录
                                    treeNode.pName = nodes.pName;//父目录名
                                    treeNode.pPath = nodes.pPath;//父目录path
                                    treeNode.folder_path = nodes.folder_path;
                                    treeNode.founder_login = nodes.founder_login;
                                    treeNode.gps_x = nodes.gps_x;
                                    treeNode.gps_y = nodes.gps_y;
                                    treeNode.bs_type = nodes.bs_type;                                    
                                    treeNode.statr_partner = nodes.statr_partner;
                                    treeNode.floor_level = nodes.floor_level;
                                    treeNode.city = nodes.city;
                                    treeNode.addr = nodes.addr;
                                    treeNode.sortType = nodes.sortType;   
                                    zTree.updateNode(treeNode);
                                    //treeNode：被编辑的节点
                                    //parentNode：需要移动到的节点
                                    //查找父节点，为0时表示移动到第一层
                                    var parentNode = null;
                                    if (nodes.pId > 0) {
                                        parentNode = zTree.getNodesByFilter(function (node) {
                                            return node.id === nodes.pId;
                                        }, true);
                                    } else {
                                        parentNode = zTree.getNodesByFilter(function (node) {
                                            return node.level === 0;
                                        }, true);
                                    }
                                    if (parentNode) {
                                        if (nodes.pId > 0)
                                            zTree.moveNode(parentNode,treeNode, 'inner');//成为parentNode子节点
                                        else
                                            zTree.moveNode(parentNode,treeNode, 'next');//成为parentNode同级后节点
                                    }
                                }
                                if (orderId != nodes.folder_order || isInit)
                                    //修改过序号，重置树
                                    docManager.bindZtree();
                                layer.msg(Lang.GeneralJson.saveAccess, { icon: 1 });
                            }
                            else
                                layer.alert(result.Msg, { icon: 5 });
                        }
                        //error: function (xhr, status, error, $form) {
                        //        layer.msg(Lang.GeneralJson.saveError, { icon: 5 });
                        //}
                    });
                }
            },
            cancel: function (li, o) {

            }
        });
    },
    //7. 打开缩略图列表
    openPicture: function (file_id) {
        var page = " <div id='createPicturePage' style='overflow-x: hidden;overflow-y:auto;margin-top:10px;margin-right:10px; display: none;'>";
        if (doc_type === "0" || doc_type === "3" || doc_type === "5")
            page += "<div class='form-group' style='position:absolute;right:30px;color:red;'><i class='fa fa-info-circle'></i>&nbsp;" + Lang.VRGoodManager.VRCommon.dbclickDelete + " <button id='btnEditFile' onclick='docManager.openPicUpPage(" + file_id + ")' class='btn btn-primary' type='button'><i class='fa fa-pencil'></i>&nbsp;" + Lang.VRGoodManager.VRCommon.upLoadImg + "</button></div>";
        else
            page += "<i class='fa fa-info-circle'></i>&nbsp;" + Lang.VRGoodManager.VRCommon.dbclickDelete + "！";
        page += "<div id='showPictureList' class='form-group' style='margin:20px 5px 15px;'>";
        //获取数据
        $.ajax({
            type: 'post',
            url: ctx + '/SourceManager/GetPicUrlByID/' + file_id,
            dataType: 'json',
            async: false,
            success: function (data) {
                if (data.Statu === 0) {
                    for (var i = 0; i < data.Data.length; i++){
                        var _fileType = "width:300px;height:220px;";//默认横版：0
                        if (data.Data[i].file_type > 0 && data.Data[i].file_type===1)
                            _fileType = "width:220px;height:300px;";//竖版：1
                        else if (data.Data[i].file_type > 0 && data.Data[i].file_type === 2)
                            _fileType = "width:300px;height:300px;";//等比：2
                        page += "<div id='img_" + data.Data[i].bag_id + "' style='position:relative;width:300px;height:330px;margin-top:20px;margin-left:20px;cursor:pointer;float:left;text-align:center;'><div style='position:absolute;bottom:10px;'><img src='" + data.Data[i].file_url.toString().replace("~", window.location.origin + $.ctx()) + "' title='" + Lang.VRGoodManager.VRCommon.dbclickDelete + "' ondblclick=docManager.delPicFileById(''," + data.Data[i].bag_id + ") style='" + _fileType + "border:1px solid #B2B2B2;border-radius:5px;display:block;margin:0 auto;'/><span>" + data.Data[i].file_name + "</span></div></div>";
                    }  
                }
                else
                    layer.msg(data.Msg, { icon: 5 });
            }
        });
        var pic = $('#createPicturePage');
        if (pic)
            pic.remove();
        //添加图片
        page += "</div></div>";
        $('body').append($(page));
        picForm = layer.open({
            title: [Lang.VRGoodManager.VRCloudWork.thumbnail, 'font-size:18px;'],
            type: 1,
            content: $('#createPicturePage'),
            scroll: true,//是否显示滚动条、默认不显示
            btn: '',
            area: ['700px', '90%'],
            yes: function (li, o) { },
            cancel: function (li, o) { }
        });
    },
    //7.1 打开缩略图上传页面
    openPicUpPage: function (file_id, pic_type) {
        //打开编辑
        picForm = layer.open({
            id: 'ifreamUpPicData',
            title: [Lang.VRGoodManager.VRCommon.upLoadImg, 'font-size:18px;'],
            type: 2,
            content: ctx + '/SourceManager/DocUpPicFile?pic_type=' + pic_type + '&file_id=' + file_id + '&doc_type=' + doc_type + "&pageType=" + pageType,
            scroll: true,//是否显示滚动条、默认不显示
            btn: [Lang.GeneralJson.publicConfirm, Lang.GeneralJson.publicCancel],
            area: ['500px', '80%'],
            yes: function (li, o) {
                var menuData = document.getElementById("ifreamUpPicData").firstChild.contentWindow.upLoadDoc();
                if (menuData === null)
                    return false;
            },
            cancel: function (li, o) {

            }
        });
    },
    //7.3 关闭缩略图文档上传窗口
    closeUpPicForm: function (data) {
        if (picForm && data && data.Statu === 0) {
            layer.close(picForm);
            //目录树图标
            if (data.Url && data.Url === "header") {
                if (data.Data.length > 0 && data.Data[0].page_type != "VRBuilding")
                    $('#showPictureList').empty();
                for (var i = 0; i < data.Data.length; i++) {
                    var _fileType = "width:300px;height:220px;";//默认横：版0
                    if (data.Data[i].folder_type > 0 && data.Data[i].folder_type === 1)
                        _fileType = "width:220px;height:300px;";//竖版：1
                    else if (data.Data[i].folder_type > 0 && data.Data[i].folder_type === 2)
                        _fileType = "width:300px;height:300px;";//等比：2
                    $("<div id='img_" + data.Data[i].folder_id + "' style='width:300px;height:330px;margin-top:20px;margin-left:20px;cursor:pointer;float:left;text-align:center;'><img onmousedown=docManager.delPicFileById(''," + data.Data[i].folder_id + ",'header','"+data.Data[i].page_type+"') src='" + data.Data[i].folder_url.toString().replace("~", window.location.origin + $.ctx()) + "' title='" + Lang.VRGoodManager.VRCommon.dbclickDelete + "'  style='" + _fileType + "border:1px solid #B2B2B2;border-radius:5px;'/><span>" + data.Data[i].folder_name + "</span></div>").appendTo($('#showPictureList'));
                }
                return false;
            }
            //缩略图
            for (var i = 0; i < data.Data.length; i++) {
                var _fileType = "width:300px;height:220px;";//默认横：版0
                if (data.Data[i].file_type > 0 && data.Data[i].file_type===1)
                    _fileType = "width:220px;height:300px;";//竖版：1
                else if (data.Data[i].file_type > 0 && data.Data[i].file_type===2)
                    _fileType = "width:300px;height:300px;";//等比：2
                var umgUrl="<div id='img_" + data.Data[i].bag_id + "' style='position:relative;width:300px;height:330px;margin-top:20px;margin-left:20px;cursor:pointer;float:left;text-align:center;'><div style='position:absolute;bottom:10px;'><img src='" + data.Data[i].file_url.toString().replace("~", window.location.origin + $.ctx()) + "' title='" + Lang.VRGoodManager.VRCommon.dbclickDelete + "' ondblclick=docManager.delPicFileById(''," + data.Data[i].bag_id + ") style='" + _fileType + "border:1px solid #B2B2B2;border-radius:5px;display:block;margin:0 auto;'/><span>" + data.Data[i].file_name + "</span></div></div>";
                $(umgUrl).appendTo($('#showPictureList'));
            }
        }
    },
    //7.4 删除缩略图、目录树图标
    delPicFileById: function(bagName,bagId,picType,pType) {
        layer.confirm(Lang.VRGoodManager.VRCommon.nodeOperTitle3 + '：' + Lang.VRGoodManager.VRCloudWork.thumbnail + " ？", {
            btn: [Lang.GeneralJson.publicConfirm, Lang.GeneralJson.publicCancel] //按钮
        }, function () {
            var layerIndex = layer.msg(Lang.GeneralJson.dataProcessing, { icon: 16, shade: [0.3, '#393D49'], time: 0 });
            $.ajax({
                type: 'post',
                url: ctx + '/SourceManager/DelPicUrlByID/' + bagId,
                dataType: 'json',
                data: { picType: picType, pageType: pType},
                async: false,
                success: function (data) {
                    layer.close(layerIndex);
                    if (data.Statu === 0) {
                        layer.msg(data.Msg, { icon: 6 });
                        $('#img_' + bagId).remove();
                    }    
                    else
                        layer.msg(data.Msg, { icon: 5 });
                }
            });
        }, function () { });
    },
    //7.5 云端素材/作品 添加购买
    payGoodsByUser: function (file_id) {
        var filePrice = 0;
        //判断是否有购买用户设置按钮
        layer.confirm(Lang.VRGoodManager.VRCloudManager.addCart, {
            btn: [Lang.GeneralJson.publicConfirm, Lang.GeneralJson.publicCancel] //按钮
        }, function () {
            var indexBatch = layer.open({
                title: [Lang.VRGoodManager.VRCloudManager.goodType, 'font-size:18px;'],
                type: 1,
                content: $('#orgFilePrice'),
                scroll: true,//是否显示滚动条、默认不显示
                btn: [Lang.GeneralJson.publicConfirm, Lang.GeneralJson.publicCancel],
                area: ['550px', '400px'],
                success: function(layero, index){
                    $.ajax({
                        type: 'post',
                        url: ctx + '/SourceManager/GetPriceList/' + file_id,
                        dataType: 'json',
                        async: false,
                        success: function (data) {
                            if (data.Statu === 0) {
                                var itemStr = "";
                                $.each(data.Data, function (i, item) {
                                    if (item.op_default)
                                        itemStr += "<option value='" + item.dis_price + "' selected=''>" + item.op_month +Lang.VRGoodManager.VRCommon.monthMoney+ "：" + item.dis_price + "</option>";
                                    else
                                        itemStr += "<option value='" + item.dis_price + "'>" + item.op_month + Lang.VRGoodManager.VRCommon.monthMoney + "：" + item.dis_price + "</option>";
                                });
                                $("#orgPrice").empty();
                                $('#orgPrice').selectpicker('refresh');
                                $('#orgPrice').append(itemStr);
                                $('#orgPrice').selectpicker('refresh');
                            }
                            else
                                layer.msg(data.Msg, { icon: 5 });
                        }
                        //,
                        //error: function () {
                        //    layer.msg(Lang.GeneralJson.dataException, { icon: 5 });
                        //}
                    });
                },
                yes: function (li, o) {
                    filePrice = $('#orgPrice').val();
                    if (!filePrice) {
                        layer.alert(Lang.GeneralJson.pleaseSelect + Lang.VRGoodManager.VRCloudManager.goodType, { icon: 5 });
                        return false;
                    }
                    layer.close(indexBatch);
                    docManager.payGood(file_id, filePrice);
                },
                cancel: function (li, o) {
                    return false;
                },
                end: function (li, o) {
                    return false;
                }
            });
        }, function () { });
    },
    payGood: function (file_id, filePrice) {
        var btnPayFileUser = $('#btnPayFileUser');
        if (!btnPayFileUser || btnPayFileUser.size() <= 0) {
            docManager.addShoppingCart(file_id, 1, filePrice);//自己购买
        } else {
            if (!payUser) {
                var index = layer.confirm(Lang.VRGoodManager.VRCloudManager.buyTitle1, {
                    btn: [Lang.VRGoodManager.VRCloudManager.buyUserBtn, Lang.GeneralJson.publicCancel] //按钮
                }, function () {
                    //用户
                    docManager.docSetObj(null, "/DocManager/GetShareDataByPerson", null, null);
                    layer.close(index);
                }, function () {
                    //角色
                    layer.close(index);
                });
            } else
                docManager.addShoppingCart(file_id, 0, filePrice);//帮别人购买
        }
    },
    //7.6 添加购物车
    addShoppingCart: function (file_id,isUser,filePrice) {
        if (!file_id) {
            layer.msg("data Exception！");
            return false;
        }
        var index = layer.msg(Lang.GeneralJson.dataProcessing, { icon: 6, time: 6000 });
        $.ajax({
            type: 'post',
            url: ctx + '/SourceManager/PayShoppingCart',
            data: { file_id: file_id, userid: payUser, myCart: isUser, file_price: filePrice },
            dataType: 'json',
            async: false,
            success: function (data) {
                layer.close(index);
                if (data.Statu === 0) {
                    layer.closeAll();
                    layer.msg(data.Msg);
                }
                else
                    layer.msg(data.Msg, { icon: 5 });
            }
            //,
            //error: function () {
            //    layer.msg(Lang.GeneralJson.dataException, { icon: 5 });
            //}
        });
    },
    //设置/取消热门推荐
    payGoodHot: function (file_id,isHot) {
        if (!file_id) {
            layer.msg("data Exception！");
            return false;
        }
        var hotTitle = "您确定设置此商品为热门推荐？",
            hot=1,
            icon = 3;
        if (isHot) {
            hot = 0;
            icon = 5;
            hotTitle = "您确定取消此商品的热门推荐？";
        }
        layer.confirm(hotTitle, {
            title: '是否热门推荐设置',
            icon: icon,
            btn: [Lang.GeneralJson.publicConfirm, Lang.GeneralJson.publicCancel] //按钮
        }, function () {
            var index = layer.msg(Lang.GeneralJson.dataProcessing, { icon: 6, time: 6000 });
            $.ajax({
                type: 'post',
                url: ctx + '/SourceManager/ModifyIsHot/' + file_id,
                dataType: 'json',
                data: { "isHot": hot},
                async: false,
                success: function (data) {
                    layer.close(index);
                    if (data.Statu === 0) {
                        $table.bootstrapTable('refresh', options);
                        layer.closeAll();
                        layer.msg(data.Msg);
                    }
                    else
                        layer.msg(data.Msg, { icon: 5 });
                }
                //,
                //error: function () {
                //    layer.msg(Lang.GeneralJson.dataException, { icon: 5 });
                //}
            });
        }, function () { });
    },
    //7.7 添加收藏夹（自己）
    payFolderByUser: function (file_id) {
        if (!file_id) {
            layer.msg("data Exception！");
            return false;
        }
        layer.confirm(Lang.VRGoodManager.VRCloudManager.favoriteTitle, {
            btn: [Lang.GeneralJson.publicConfirm, Lang.GeneralJson.publicCancel] //按钮
        }, function () {
            var index = layer.msg(Lang.GeneralJson.dataProcessing, { icon: 6, time: 6000 });
            $.ajax({
                type: 'post',
                url: ctx + '/SourceManager/PayFolderByUser/' + file_id,
                dataType: 'json',
                async: false,
                success: function (data) {
                    layer.close(index);
                    if (data.Statu === 0) {
                        layer.closeAll();
                        layer.msg(data.Msg);
                    }
                    else
                        layer.msg(data.Msg, { icon: 5 });
                }
                //,
                //error: function () {
                //    layer.msg(Lang.GeneralJson.dataException, { icon: 5 });
                //}
            });
        }, function () { }); 
    },
    //7.8关闭购买窗口
    closePayForm: function () {
        if (indexForm)
            layer.close(indexForm);
    },
    //8.0 cookie获取语言
    getLanguage: function () {
        var lang = $.cookie('Language');
        if (!lang)
            lang = "zh";
        return lang;
    }
}